import {commGet, commPost, commPut, deleteAction} from "@utils/service/index.js";
/**
 * 获取用户列表
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function getUserList(data) {
    return commGet({
        url: "/sys/user/list",
        method: 'get',
        data
    })
}

/**
 * 检查用户名是否重复
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function checkUserName(data){
    return commGet({
        url: "/sys/duplicate/check",
        method: 'get',
        data
    })
}

/**
 * 获取角色列表
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function getRoleList(data={}){
    return commGet({
        url: "/sys/role/queryall",
        method: 'get',
        data
    })
}

/**
 * 新增用户
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addUser(data){
    return commPost({
        url: "/sys/user/add",
        method: 'post',
        data
    })
}

/**
 * 删除用户
 * @param url
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteOneUser(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

/**
 * 编辑用户
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */

export function editUser(data){
    return commPost({
        url: "/sys/user/edit",
        method: 'post',
        data
    })
}

/**
 * 冻结/解冻用户
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function frozenBatch(data){
    return commPut({
        url:'/sys/user/frozenBatch',
        data
    })
}

/**
 * 修改密码
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function changePassword(data){
    return commPut({
        url:'/sys/user/changePassword',
        method: 'put',
        data,
    })
}

/**
 * 获取用户列表
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function queryByUserName(data){
    return commGet({
        url: "/sys/sysUserAgent/queryByUserName",
        method: 'get',
        data
    })
}

/**
 * 获取用户角色列表
 * @param data
 * @returns {Promise<* extends (object & {then(onfulfilled: infer F, ...args: infer _): any}) ? (F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never) : *>}
 */
export function queryUserRoleList(data){
    return commGet({
        url: "/sys/user/userRoleList",
        method: 'get',
        data
    })
}

/**
 *  新增用户角色
 * @param url
 * @param data
 * @returns {Promise<T>}
 */
export function deleteUserRole(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

export function queryUserRole(data){
    return commGet({
        url: "/sys/user/queryUserRole",
        method: 'get',
        data
    })
}
export function queryUserSync(data){
    return commPost({
        url: "/sys/user/sync",
        method: 'post',
        data
    })
}


